package br.ufrj.pesc.solr;

import java.net.MalformedURLException;
import java.text.SimpleDateFormat;

import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.LBHttpSolrServer;
import org.apache.solr.client.solrj.response.QueryResponse;

public abstract class SolrHandler {
	
	public static void main(String[] args){
	    SolrServer server;
		try {
			server = new LBHttpSolrServer("http://127.0.0.1:28080/solr/","http://192.168.8.121:28080/solr/","http://192.168.8.6:28080/solr/");
	    SolrQuery query = new SolrQuery();

	    query.setQuery("*:*");
	    query.setFacet(true);
	    query.set("wt", "json");
	    query.setRows(5);
	    query.setStart(0);
	    
	    System.out.println(query.toString());

	    QueryResponse response = server.query(query);

//	    System.out.println(response);
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SolrServerException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	protected static final String url = "http://127.0.0.1:28080/solr/,http://192.168.8.121:28080/solr/,http://192.168.8.6:28080/solr/";
	protected SimpleDateFormat formatadorDeData = new SimpleDateFormat(
			"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
	protected static LBHttpSolrServer server;
	protected SolrQuery query;
	
	public SolrHandler() throws MalformedURLException{
		if (server==null){
			server = new LBHttpSolrServer("http://127.0.0.1:28080/solr/","http://192.168.8.121:28080/solr/","http://192.168.8.6:28080/solr/");
		}
	}

}
